GIS 学会 FOSS4G 分科会ワークショップ 報告

馬場美彦

12 November 2022

GIS 学会

GIS 学会 FOSS4G 分科会ワークショップ

「Geocomputation with R 勉強会」

10月29日(土) 9:30 - 12:00

報告

Geocomputation with R

GIS 学会

  • 青木、岩崎、小野原、馬場で企画。
  • GeoCompR Chapter 2 を実践
  • 申し込み 53名
    • R 初心者 37、中級者 16
    • GIS 初心者 30、中上級者 23
  • 10/29 8:20 - 12:00

風景

進行

  • ブレイクアウトルーム1
    • 馬場が Chapter 2 を解説
    • 岩崎がツッコミ
  • ブレイクアウトルーム2
    • もくもく会(青木、小野原)
    • Chapter 2 & 3

反省 1/2

事後アンケートは用意しなかった。

コードを実行するだけでは何をしているか分かりづらい。

あらためて講義を録画して、YouTube (無料)か Udemy などで公開すると良いかもしれない。

反省 2/2

年に数回、対面で勉強会したい。
(京都の知人で参加できなかった方が、有料でもよいので京都でやってくれと言っています。)

S2 については、もっと勉強する必要がある。

主なトピック

日本のデータ

  • 原著は世界のデータ
    • 日本のデータで試したい

    • パッケージを作成しました

geojp

library(geojp)
library(sf)
# 旭川市 (01, 204), 鹿児島市 (46, 201)
strTempDir <- "~/data.noindex"
sfFukushi <- geojp::read_landnuminfo_welfare("01", "204", data_dir = strTempDir)
## [1] "Downloaded the file and saved in https://nlftp.mlit.go.jp/ksj/gml/data/P14/P14-21/P14-21_01_GML.zip"
## [1] "Found a geojson file: /var/folders/q2/grwlh1bn27l2t43bqg7dxhwr0000gn/T//RtmpM0eOrL/P14-21_01.geojson"
sfChika <- geojp::read_landnuminfo_officiallandprice("01", data_dir = strTempDir)
## [1] "Downloaded the file and saved in https://nlftp.mlit.go.jp/ksj/gml/data/L01/L01-21/L01-21_01_GML.zip"
## [1] "Found a geojson file: /var/folders/q2/grwlh1bn27l2t43bqg7dxhwr0000gn/T//RtmpM0eOrL/*L01-21_01*.geojson"
## [1] "Found a geojson file: /var/folders/q2/grwlh1bn27l2t43bqg7dxhwr0000gn/T//RtmpM0eOrL/L01-21_01_GML\\L01-21_01.geojson"
sfChika <- st_transform(sfChika, 6668)
attr(sfFukushi, "sourceName")
## [1] "「国土数値情報(福祉施設データ)」(国土交通省)"
attr(sfChika, "sourceName")
## [1] "「国土数値情報(地価公示データ)」(国土交通省)"

S2

  • Google による球面幾何学ライブラリ

  • GEOS は平面幾何学

  • S2 に対応しているのは、現状では R のみ

S2 と GEOS

library(sf)
# Spatial join (point - point) with S2
sf::sf_use_s2(TRUE)
start_time = Sys.time()
nearest_point = sf::st_nearest_feature(sfFukushi,sfChika)
sfFukushi$L01_006_S2 <- sfChika[nearest_point,"L01_006"]$L01_006
sfFukushi$dist_Chika_S2 = sf::st_distance(sfFukushi, sfChika[nearest_point,], by_element=TRUE)
Sys.time() - start_time
## Time difference of 0.4416351 secs
# Spatial join (point - point) with GEOS
sf::sf_use_s2(FALSE)
start_time = Sys.time()
nearest_point = sf::st_nearest_feature(sfFukushi,sfChika)
sfFukushi$L01_006_GEOS <- sfChika[nearest_point,"L01_006"]$L01_006
sfFukushi$dist_Chika_GEOS = sf::st_distance(sfFukushi, sfChika[nearest_point,], by_element=TRUE)
Sys.time() - start_time
## Time difference of 1.297735 mins
# Compare S2 and GEOS
t.test(as.numeric(sfFukushi$dist_Chika_S2), as.numeric(sfFukushi$dist_Chika_GEOS), paired = TRUE)
## 
##  Paired t-test
## 
## data:  as.numeric(sfFukushi$dist_Chika_S2) and as.numeric(sfFukushi$dist_Chika_GEOS)
## t = -27.767, df = 12200, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -7.456647 -6.473297
## sample estimates:
## mean of the differences 
##               -6.964972
library(tmap)
tmap_mode(mode = "view")
myTm <- tm_shape(sfFukushi) + tm_dots()
myTm <- myTm + tm_shape(sfChika) + tm_dots(col = "red")
myTm <- myTm + tm_basemap(geojp::get_tile_server())
myTm

これから

毎週の勉強会

研究室で先輩が後輩に教えるような勉強会

https://saturdaymorning.connpass.com/

各地でセミナー

GeoCompR の完成

来年の GIS 学会

YouTube?

仙台?つくば?京都?

ありがとうございました